<?php
/**
 * Description
 *
 * PHP version 7
 *
 * @category Custom
 * @package  Custom
 * @author   ryu <mo5467@126.com>
 * @date     2020-04-29 01:26:15
 * @lastTime 2020-05-01 23:49:42
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     none
 */
namespace Test\Unit;

use Design\Behavioral\Visitor\User;
use Design\Behavioral\Visitor\Group;
use Design\Behavioral\Visitor\RecordingVisitor;

class VisitorTest extends \Test\BaseTest
{

    private $visitor;


    public function setUp() : void
    {
        $this->visitor = new RecordingVisitor();

    }//end setUp()



    /**
     * Undocumented function
     *
     * @return       void
     */
    public function testVisit()
    {
        $user = new User('Dominik');
        $user->accept($this->visitor);
        $this->assertSame($user, $this->visitor->getVisited()[0]);
        $this->assertSame('User Dominik', $this->visitor->getVisited()[0]->getName());

        $group = new Group('Administrators');
        $group->accept($this->visitor);
        $this->assertSame($group, $this->visitor->getVisited()[1]);
        $this->assertSame('Group Administrators', $this->visitor->getVisited()[1]->getName());
    }//end testVisit()


}//end class
